<template>
	<div class="col-md-2 sidebar clearfix" id="bs-example-navbar-collapse-1">
	  <div class="sidebar-abs col-md-2">
	  	<ul class="nav nav-sidebar panel-group" id="left-nav">
			<li class="panel">
				<div class="left_nav" data-toggle="collapse" data-parent="#left-nav" href="#part1">基础管理</div>
				<div class="collapse" id="part1">
					<p @click="page_select('product_manage','产品管理')">产品管理</p>
					<p @click="page_select('material_manage','物料管理')">物料管理</p>
					<p @click="page_select('supplier_manage','供应商管理')">供应商管理</p>
					<p @click="page_select('client_manage','客户管理')">客户管理</p>
					<p @click="page_select('ware_manage','仓库管理')">仓库管理</p>
					<p @click="page_select('inventory_danger','库存预警')">库存预警</p>
					<p @click="page_select('unit_manage','单位管理')">单位管理</p>
					<p @click="page_select('base_manage','基础管理')">基础管理</p>
				</div>
			</li>
			<li class="panel">
				<div class="left_nav" data-toggle="collapse" data-parent="#left-nav" href="#part2">报表管理</div>
				<div class="collapse" id="part2">
					<p @click="page_select('purchase_manage','采购报表')">采购报表</p>
					<p>标签2</p>
					<p>标签3</p>
				</div>
			</li>
			<li class="panel">
				<div class="left_nav" data-toggle="collapse" data-parent="#left-nav" href="#part3">一级标签</div>
				<div class="collapse" id="part3">
					<p>标签1</p>
					<p>标签2</p>
					<p>标签3</p>
				</div>
			</li>
		</ul>
	  </div>
		
	</div>
</template>
<script>
	export default {
		name: 'app',
		data() {
			return {

			}
		},
		methods: {
			page_select(page_name,tab_name) {
				var flag = true;
				var index=0;
				var tab = this.$store.state.tab;
				var length=this.$store.state.tab.length;
				for(var i = 0; i < tab.length; i++) {
					if(page_name == tab[i].name) {
						flag = false
						index=i
					}
				}
				this.page_show(flag,page_name,tab_name,index,length)
			},
			page_show(flag,page_name,tab_name,index,length) {
				if(flag == false) {
					this.$store.state.now = page_name
					this.$store.state.index = index
				} else {
					var str = [{
						name: page_name,
						tab_name: tab_name,
					}]
					this.$store.state.index = length
					this.$store.state.now = page_name
					this.$store.state.tab = this.$store.state.tab.concat(str)
				}

			}
		}
	}
</script>